import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.find_element(By.ID, 'kw').send_keys("美女")
driver.find_element(By.ID, 'su').click()
time.sleep(2)
#最底层
js1 = "window.scrollTo(0,document.body.scrollHeight"
# driver.execute_script(js1)
# # 最顶层
# time.sleep(2)
# js2 = "window.scrollTo(0,0)"
# driver.execute_script(js2)

# 第二种写法
# time.sleep(2)
# js3 = "window.scrollTo({left:0,top:document.body.scrollHeight,behavior:'smooth'})"
# driver.execute_script(js3)

# 聚焦
ele = driver.find_element(By.PARTIAL_LINK_TEXT,"菜鸟教程")
driver.execute_script("arguments[0].scrollIntoView();", ele)
time.sleep(3)

time.sleep(3)
driver.quit()